import java.util.List;

/**
 * A File should has a title, one or several authors and a isbn number.
 * 
 * A book or a magazine is a file.
 * 
 * @author Xi Luo
 * 
 */

public class File {

   protected String title;
   // authors of the file
   protected List<Author> authors;
   protected String isbn;
   // contains the author email string, e.g. "pr-lieblich@optivo.de, pr-walter@optivo.de"
   protected String authorString;

   public String getTitle() {
      return title;
   }

   public void setTitle(String title) {
      this.title = title;
   }

   public List<Author> getAuthors() {
      return authors;
   }

   public void setAuthors(List<Author> authors) {
      this.authors = authors;
   }

   public String getIsbn() {
      return isbn;
   }

   public void setIsbn(String isbn) {
      this.isbn = isbn;
   }

   public String getAuthorString() {
      return authorString;
   }

   public void setAuthorString(String authorString) {
      this.authorString = authorString;
   }

   /**
    * Check if the given author writes the file.
    * 
    * @param id id can be email, first name of last name of the given author
    * @return
    */
   public boolean writenByAuthor(String id) {
      for (Author author : authors) {
         if (id.equals(author.getEmail()) || id.equals(author.getFirstName()) || id.equals(author.getLastName())) {
            return true;
         }
      }
      return false;
   }
}
